package com.woniuxy.springboot221.web;

import com.woniuxy.springboot221.entity.Charactor;
import com.woniuxy.springboot221.entity.Course;
import com.woniuxy.springboot221.entity.Subject;
import com.woniuxy.springboot221.service.CharactorService;
import com.woniuxy.springboot221.service.CourseService;
import com.woniuxy.springboot221.service.SubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
public class IndexController {
    @Autowired
    CourseService courseService;
    @Autowired
    RedisTemplate redisTemplate;

    @GetMapping
    public String getIndex(Model model) {
       List<Course>courses=courseService.listCourse();
       redisTemplate.opsForValue().set("courses",courses);
       List<Course>list= (List<Course>) redisTemplate.opsForValue().get("courses");

        System.out.println();
       model.addAttribute("courses",courses);
        return "index";
    }
}
